-- ======================================================================
-- Hell Logic Sniffer Addon 
-- 
-- Copyright 2013 Hell-Prototypes
--
-- http://www.hellprototypes.com/
-- ======================================================================

--Uncomment below line to enable this plugin
--ModuleClass = "LS_PLUGIN"
ModuleName  = "@.GetDecodeData"
ModuleTip   = "Demo: Get decode data"

function main ()
    local ch = LS_API.InputBox(0, "Input channel num(0~15):")
    if ch >= 16 or ch < 0 then
        LS_API.MessageBox("Error channel num: " .. ch)
        return
    end

    local Decoded = LS_API.GetChannelDecodedData(3)
    
    if type(Decoded) ~= "table" then
		LS_API.MessageBox("No decoded data in channel : " .. ch)
		return
	end

    LS_API.ReportPushBack("=======================")
    LS_API.ReportPushBack("Decoded table size : " .. #Decoded/2)
    LS_API.ReportPushBack("----------------------")

    index = 1
    while index < #Decoded do
        LS_API.ReportPushBack( (index/2 + 0.5) .. ": " .. Decoded[index] .. "\t = \t" .. Decoded[index+1])
        index = index + 2
    end
    LS_API.ReportPushBack("=======================")
end

